<?php


namespace App\Admin\Controller\Auth;


use App\Admin\Controller\AdminBaseController;
use App\Admin\Requests\Auth\User\LoginRequest;
use App\Admin\Services\Auth\UserService;

class UserController extends AdminBaseController {
    public $noAuthActionList = ['login'];
    public $exceptActionList = ['logout'];
    
    /**
     * @param LoginRequest $request
     * @param UserService  $userService
     *
     * @return mixed
     * @throws \App\Admin\Exceptions\Auth\UserException
     */
    public function login(LoginRequest $request, UserService $userService) {
        $credentials = $request->only(['username', 'password']);
        $res         = $userService->doLogin($credentials);
        
        return $this->success($res);
    }
    
    /**
     * 用户退出
     * @return mixed
     */
    public function logout() {
        \Illuminate\Support\Facades\Auth::guard()->logout();
        
        return $this->success();
    }
}